import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
//用于配置静态文件访问
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';
import { json } from 'express';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  app.enableCors({
    origin: true,
    methods: 'GET,PUT,POST',
    allowedHeaders: 'Content-Type,Authorization',
    exposedHeaders: 'Content-Range,X-Content-Range',
    credentials: true,
  });
  //配置静态文件访问目录
  app.useStaticAssets(join(__dirname, '../public/images'), {
    prefix: '/images/',
  });

  // 配置请求体内存
  app.use(json({ limit: '50mb' }));

  await app.listen(8888);
}

bootstrap();
